package com.fauks.ssm.mybatis.plus.injector;

import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

public class MyMetaObjectHandler extends MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        Object last_name = getFieldValByName("name", metaObject);
        if (last_name == null) {
            System.out.println("*******插入操作 满足填充条件*******");
            setFieldValByName("name", "xxx", metaObject);
        }
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        Object last_name = getFieldValByName("name", metaObject);
        if (last_name == null) {
            System.out.println("*******更新操作 满足填充条件*******");
            setFieldValByName("name", "默认更新姓名", metaObject);
        }
    }
}
